package co.com.smart.persistence.entity;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import co.com.smart.persistence.entity.dto.SmartDatosMaestro;
import co.com.smart.persistence.entity.util.AbstractFacade;

/**
 * Session Bean implementation class DatosMaestrosFacade
 */
@Stateless(
		name		= "DatosMaestrosFacade", 
		mappedName 	= "ejb/DatosMaestrosFacade")
public class DatosMaestrosFacade extends AbstractFacade<SmartDatosMaestro> implements DatosMaestrosFacadeLocal {

	@PersistenceContext(unitName = "SnakeServicesPU")
	private EntityManager em;
    /**
     * Default constructor. 
     */
    public DatosMaestrosFacade() {
    	super(SmartDatosMaestro.class);
    }
    
    @Override
    protected EntityManager getEntityManager() {
    	return em;
    }

	@Override
	public List<SmartDatosMaestro> consultarDatosMaestroCd(String codigoMaestro) {
		StringBuilder  sQuery = new StringBuilder("SELECT s FROM SmartDatosMaestro s join s.smartMaestro p ");
		sQuery.append(" where p.smFhretiro is null and p.smComaestros = :codigoMaestro");
		
		Query query = em.createQuery(sQuery.toString() );
		query.setParameter("codigoMaestro", codigoMaestro);
		return query.getResultList();		
	}
    
   

}
